
class Solution {
public:
    string reverseWords(string s) {
        int n=s.size();
        auto left=s.begin();
        auto right=s.begin();
        int l=0,r=0;
        while(r<n+1&&l<n+1)
        {
            if(s[r]== ' '||r==n)
            {
                reverse(left,right);
                left=right+1;
                l=r+1;
            }
            right++;
            r++;
        }
        return s;
    }
};